'This class was converted from C# code created by abi.exDream.com to VB.Net 2005/2008 class by Danny C. McNaught

#Region "Imports directives"
Imports System
Imports System.IO
Imports System.Collections
Imports System.Windows.Forms
#If UNIT_TESTING Then
Imports NUnit.Framework
#End If
Imports System.ComponentModel
Imports System.Threading
#End Region

Namespace VBCodeCommenter
    ''' <summary>The Class Log
    ''' </summary>
    ''' <remarks>
    ''' 	<para><b>History:</b></para>
    ''' <list type="table">
    ''' 	<listheader>
    ''' 		<term>Term</term>
    ''' 		<description>Description</description>
    ''' 	</listheader>
    ''' 	<item>
    ''' 		<term>Developer: Danny C. McNaught<para>Developer Company: EDS</para> <para>Developer Phone: (919) 325-7311</para> <para>Developer Email: danny.mcnaught@eds.com</para> <para>Developed on: W2PZZ50H01</para> <para>Date: 9/10/2007</para><para>Time: 7:20:44 AM</para></term>
    ''' 		<description>Created XML Comment. </description>
    '''	''' 	</item>
    ''' </list>
    ''' </remarks>
    ''' <example>
    ''' </example>
    Public Class Log
#Region "Variables"
        ''' <summary>Initialized Variable [writer] Stream writer = Nothing
        ''' </summary>
        ''' <remarks>
        ''' 	<para><b>History:</b></para>
        ''' <list type="table">
        ''' 	<listheader>
        ''' 		<term>Term</term>
        ''' 		<description>Description</description>
        ''' 	</listheader>
        ''' 	<item>
        ''' 		<term>Developer: Danny C. McNaught<para>Developer Company: EDS</para> <para>Developer Phone: (919) 325-7311</para> <para>Developer Email: danny.mcnaught@eds.com</para> <para>Developed on: W2PZZ50H01</para> <para>Date: 9/10/2007</para><para>Time: 7:20:50 AM</para></term>
        ''' 		<description>Created XML Comment. </description>
        ''' 	</item>
        ''' </list>
        ''' </remarks>
        ''' <example>
        ''' </example>
        Private Shared writer As StreamWriter = Nothing
        ''' <summary>Constant Variable [LogFilename] As <seealso cref= "System.String"/> = "DevExpress.CodeRush.Diagnostics.Menus.Log.txt"
        ''' </summary>
        ''' <remarks>
        ''' 	<para><b>History:</b></para>
        ''' <list type="table">
        ''' 	<listheader>
        ''' 		<term>Term</term>
        ''' 		<description>Description</description>
        ''' 	</listheader>
        ''' 	<item>
        ''' 		<term>Developer: Danny C. McNaught<para>Developer Company: EDS</para> <para>Developer Phone: (919) 325-7311</para> <para>Developer Email: danny.mcnaught@eds.com</para> <para>Developed on: W2PZZ50H01</para> <para>Date: 9/10/2007</para><para>Time: 7:20:53 AM</para></term>
        ''' 		<description>Created XML Comment. </description>
        ''' 	</item>
        ''' </list>
        ''' </remarks>
        ''' <example>
        ''' </example>
        Private Const LogFilename As String = "DevExpress.CodeRush.Diagnostics.Menus.Log.txt"
#End Region

#Region "Static constructor to create log file"
        ''' <summary>
        ''' Static constructor
        ''' </summary>
        ''' <remarks>
        ''' 	<para><b>History:</b></para>
        ''' <list type="table">
        ''' 	<listheader>
        ''' 		<term>Term</term>
        ''' 		<description>Description</description>
        ''' 	</listheader>
        ''' <item>
        ''' 		<term>Developer: Danny C. McNaught<para>Developer Company: EDS</para> <para>Developer Phone: (919) 325-7311</para> <para>Developer Email: danny.mcnaught@eds.com</para> <para>Developed on: W2PZZ50H01</para> <para>Date: 9/10/2007</para><para>Time: 7:21:03 AM</para></term>
        ''' 		<description>Created XML Comment. </description>
        ''' 	</item>
        ''' </list>
        ''' </remarks>
        ''' <example>
        ''' </example>
        Shared Sub New()
            Try
                ' Open file
                Dim file As New FileStream(LogFilename, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite)

                ' Check if file is too big (more than 2 MB),
                ' in this case we just kill it and create a new one :)
                If file.Length > 2 * 1024 * 1024 Then
                    file.Close()
                    file = New FileStream(LogFilename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)
                End If
                ' if (file.Length)
                ' Associate writer with that, when writing to a new file,
                ' make sure UTF-8 sign is written, else don't write it again!
                If file.Length = 0 Then
                    writer = New StreamWriter(file, System.Text.Encoding.UTF8)
                Else
                    writer = New StreamWriter(file)
                End If

                ' Go to end of file
                writer.BaseStream.Seek(0, SeekOrigin.[End])

                ' Enable auto flush (always being up to date when reading!)
                writer.AutoFlush = True

                ' Add some info about this session
                writer.WriteLine("")
                writer.WriteLine("''' Session started at: " + DateTime.Now.Year.ToString("00") + "-" + DateTime.Now.Month.ToString("00") + "-" + DateTime.Now.Day.ToString("00") + " " + DateTime.Now.Hour.ToString("00") + ":" + DateTime.Now.Minute.ToString("00") + ":" + DateTime.Now.Second.ToString("00"))
                writer.WriteLine("''' " + Application.ProductName + " v" + Application.ProductVersion)
                writer.WriteLine("")
            Catch
                ' ignore any file exceptions, if file is not
                ' create able (e.g. on a CD-Rom) it doesn't matter
                ' try
                ' catch
            End Try
        End Sub
        ' Log()
#End Region
#Region "Write log entry"
        ''' <summary>
        ''' Writes a LogType and info/error message string to the Log file
        ''' </summary>
        ''' <param name="message">Parameter message As <seealso cref= "System.String"/></param>
        ''' <remarks>
        ''' 	<para><b>History:</b></para>
        ''' <list type="table">
        ''' 	<listheader>
        ''' 		<term>Term</term>
        ''' 		<description>Description</description>
        ''' 	</listheader>
        ''' <item>
        ''' 		<term>Developer: Danny C. McNaught<para>Developer Company: EDS</para> <para>Developer Phone: (919) 325-7311</para> <para>Developer Email: danny.mcnaught@eds.com</para> <para>Developed on: W2PZZ50H01</para> <para>Date: 9/10/2007</para><para>Time: 7:21:20 AM</para></term>
        ''' 		<description>Created XML Comment. </description>
        ''' 	</item>
        ''' </list>
        ''' </remarks>
        ''' <example>
        ''' </example>
        Public Shared Sub Write(ByVal message As String)
            Try
                Dim ct As DateTime = DateTime.Now
                Dim s As String = "[" + ct.Hour.ToString("00") + ":" + ct.Minute.ToString("00") + ":" + ct.Second.ToString("00") + "] " + message
                writer.WriteLine(s)
            Catch
                ' ignore any file exceptions, if file is not
                ' writable (e.g. on a CD-Rom) it doesn't matter
                ' try
            End Try
            ' catch
        End Sub

#End Region
    End Class
    ' class Log
End Namespace